﻿''============================================================================
''OMANE - Fenêtre constituant l'ossature de l'outil OMANE
''Copyright © 2010 PIERRE TISSOT CONSEIL / NATIXIS ASSURANCES
''=============================================================================

Imports System.Windows.Forms
Imports PTIC_GestionBDD
Imports Actuariat
Imports PTIC_Util
Imports OMANE.moteurTauxGaranti2

Public Class Ossature
    Implements PTIC_Util.IObserver

#Region "Variables de classe"

#Region "Gestion de l'affichage"
    'Les formulaires enfants - les fenêtres filles
    Protected frmProcessusEtude As frmEtudeVisuTraitements
    Protected frmDonEncours As frmDonneesEncours
    Protected frmDonReferentielles As frmDonneesReferentielles
    Protected frmDonSegmentation As frmDonneesSegmentation
    Protected frmDonTechniques As frmDonneesTechniques
    Protected frmResultats As frmResultatsModele1
    Protected frmEnCours As Form

    Protected _saveNodeProjComptes As TreeNode
    Protected _saveParentNodeProjComptes As TreeNode

#End Region

#Region "Composants métier"

    'Univers de manipulation des bases de données (modèle + contrôleur)
    Protected WithEvents _universBDD As UniversOMANE
    'Protected _listeParametres As ParametresList

    'Contrôleur permettant de modifier les paramètres de l'étude
    Protected _ControleurParametres As IListControleursParametres
    Protected _controleurOMANE As Controleur

#End Region

#End Region

#Region "Constructeur / Initialisation des objets métier"

    Public Sub New(ByVal controleurOMANE As Controleur, _
                   ByVal universOMANE As UniversOMANE)

        ' Cet appel est requis par le Concepteur Windows Form.
        InitializeComponent()

        _controleurOMANE = controleurOMANE
        _ControleurParametres = controleurOMANE.controleListeParametres
        _universBDD = universOMANE
    End Sub

#End Region

#Region "Fenêtre principale / Initialisation de l'IHM"

    Private Sub loadAffichageOssature()
        'Initialisation de l'affichage de l'ossature
        Me.WindowState = FormWindowState.Maximized
        initPosSplitters()
        initCaractSplitters()
        deroule_treeView(PtiC_trv_Arbo)

    End Sub

    Private Sub loadAffichageFenetresFilles()

        'Création et initialisation des fenêtres filles
        frmProcessusEtude = New frmEtudeVisuTraitements(_universBDD)
        frmDonEncours = New frmDonneesEncours(_universBDD)
        frmDonReferentielles = New frmDonneesReferentielles(_universBDD)
        frmDonSegmentation = New frmDonneesSegmentation(_universBDD)
        frmDonTechniques = New frmDonneesTechniques(_universBDD, _controleurOMANE)
        frmResultats = New frmResultatsModele1(_universBDD, _controleurOMANE)

        'Définition des observations effectuées par les vues
        'Observations de la segmentation
        _universBDD.Segmentation.ajouteObserver(frmDonSegmentation)
        _universBDD.Segmentation.ajouteObserver(frmResultats)
        _universBDD.Segmentation.ajouteObserver(frmDonTechniques)
        _universBDD.Segmentation.ajouteObserver(_universBDD.listeTraitements.getTraitMoteurMethode2)

        'Observation du traitement de qualification de la table d'encours et de ses correspondances
        _universBDD.listeTraitements.getTraitTbleEncours.ajouteObserver(frmDonEncours)
        For Each corresp As Correspondance In _universBDD.listeTraitements.getTraitTbleEncours.ListeChampsSortie.Values
            corresp.ajouteObserver(frmDonEncours)
        Next

        'Observation des paramètres
        For Each p As baseParametre In _universBDD.ListeParametres.Values
            If p.nom <> nomTx_CommiContA Then
                p.ajouteObserver(frmDonTechniques)
            Else
                p.ajouteObserver(frmResultats)
            End If
        Next

        'Observation de l'univers OMANE
        _universBDD.ajouteObserver(frmDonTechniques)
        _universBDD.ajouteObserver(Me)
        _universBDD.listeTraitements.getTraitMoteurMethode1.ajouteObserver(frmResultats)
        _universBDD.listeTraitements.getTraitMoteurMethode1.ajouteObserver(Me)
        CType(_universBDD.listeTraitements.getTraitMoteurMethode2, Moteur_Methode2).scenarioCentral.ajouteObserver(Me)

        _ControleurParametres.defaut()


        frmProcessusEtude.MdiParent = Me
        frmDonEncours.MdiParent = Me
        frmDonReferentielles.MdiParent = Me
        frmDonSegmentation.MdiParent = Me
        frmDonTechniques.MdiParent = Me
        frmResultats.MdiParent = Me

        Me.PtiC_SplitTravAide.Panel1.Controls.Add(frmProcessusEtude)
        Me.PtiC_SplitTravAide.Panel1.Controls.Add(frmDonEncours)
        Me.PtiC_SplitTravAide.Panel1.Controls.Add(frmDonReferentielles)
        Me.PtiC_SplitTravAide.Panel1.Controls.Add(frmDonSegmentation)
        Me.PtiC_SplitTravAide.Panel1.Controls.Add(frmDonTechniques)
        Me.PtiC_SplitTravAide.Panel1.Controls.Add(frmResultats)

        frmProcessusEtude.Dock = DockStyle.Fill
        frmDonEncours.Dock = DockStyle.Fill
        frmDonReferentielles.Dock = DockStyle.Fill
        frmDonSegmentation.Dock = DockStyle.Fill
        frmDonTechniques.Dock = DockStyle.Fill
        frmResultats.Dock = DockStyle.Fill

        frmProcessusEtude.Visible = False
        frmDonEncours.Visible = True
        frmDonReferentielles.Visible = False
        frmDonSegmentation.Visible = False
        frmDonTechniques.Visible = False
        frmResultats.Visible = False

        frmEnCours = frmDonEncours

    End Sub

    Private Sub Ossature_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        loadAffichageOssature()
        loadAffichageFenetresFilles()

    End Sub

    Private Sub Ossature_SizeChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.SizeChanged
        initPosSplitters()
    End Sub

#End Region

#Region "Le menu"

    Private Sub ShowNewForm(ByVal sender As Object, ByVal e As EventArgs) Handles NewToolStripMenuItem.Click, NewToolStripButton.Click, NewWindowToolStripMenuItem.Click
    End Sub
    Private Sub OpenFile(ByVal sender As Object, ByVal e As EventArgs) Handles OpenToolStripMenuItem.Click, OpenToolStripButton.Click
    End Sub
    Private Sub SaveAsToolStripMenuItem_Click(ByVal sender As Object, ByVal e As EventArgs) Handles SaveAsToolStripMenuItem.Click
    End Sub
    Private Sub ExitToolsStripMenuItem_Click(ByVal sender As Object, ByVal e As EventArgs) Handles ExitToolStripMenuItem.Click
        Me.Close()
    End Sub
    Private Sub CutToolStripMenuItem_Click(ByVal sender As Object, ByVal e As EventArgs) Handles CutToolStripMenuItem.Click
        ' Utilisez My.Computer.Clipboard pour insérer les images ou le texte sélectionné dans le Presse-papiers
        Dim hwnd As IntPtr = GetFocus()
        Dim ctrl As Control = Control.FromHandle(hwnd)
        If TypeOf ctrl Is TextBox Then
            CType(ctrl, TextBox).Cut()
        End If
    End Sub
    Private Sub CopyToolStripMenuItem_Click(ByVal sender As Object, ByVal e As EventArgs) Handles CopyToolStripMenuItem.Click
        ' Utilisez My.Computer.Clipboard pour insérer les images ou le texte sélectionné dans le Presse-papiers
        Dim hwnd As IntPtr = GetFocus()
        Dim ctrl As Control = Control.FromHandle(hwnd)
        If TypeOf ctrl Is TextBox Then
            CType(ctrl, TextBox).Copy()
        End If
        ''MsgBox("Vous avez cliqué sur Ctrl+S" & Control.FromHandle(hwnd).Name)
    End Sub
    Private Sub PasteToolStripMenuItem_Click(ByVal sender As Object, ByVal e As EventArgs) Handles PasteToolStripMenuItem.Click
        'Utilisez My.Computer.Clipboard.GetText() ou My.Computer.Clipboard.GetData pour extraire les informations du Presse-papiers.
        Dim hwnd As IntPtr = GetFocus()
        Dim ctrl As Control = Control.FromHandle(hwnd)
        If TypeOf ctrl Is TextBox Then
            CType(ctrl, TextBox).Paste()
        End If
    End Sub
    Private Sub ToolBarToolStripMenuItem_Click(ByVal sender As Object, ByVal e As EventArgs) Handles ToolBarToolStripMenuItem.Click
        Me.ToolStrip.Visible = Me.ToolBarToolStripMenuItem.Checked
    End Sub
    Private Sub StatusBarToolStripMenuItem_Click(ByVal sender As Object, ByVal e As EventArgs) Handles StatusBarToolStripMenuItem.Click
        Me.StatusStrip.Visible = Me.StatusBarToolStripMenuItem.Checked
    End Sub
    Private Sub CascadeToolStripMenuItem_Click(ByVal sender As Object, ByVal e As EventArgs) Handles CascadeToolStripMenuItem.Click
        Me.LayoutMdi(MdiLayout.Cascade)
    End Sub
    Private Sub TileVerticalToolStripMenuItem_Click(ByVal sender As Object, ByVal e As EventArgs) Handles TileVerticalToolStripMenuItem.Click
        Me.LayoutMdi(MdiLayout.TileVertical)
    End Sub
    Private Sub TileHorizontalToolStripMenuItem_Click(ByVal sender As Object, ByVal e As EventArgs) Handles TileHorizontalToolStripMenuItem.Click
        Me.LayoutMdi(MdiLayout.TileHorizontal)
    End Sub
    Private Sub ArrangeIconsToolStripMenuItem_Click(ByVal sender As Object, ByVal e As EventArgs) Handles ArrangeIconsToolStripMenuItem.Click
        Me.LayoutMdi(MdiLayout.ArrangeIcons)
    End Sub
    Private Sub CloseAllToolStripMenuItem_Click(ByVal sender As Object, ByVal e As EventArgs) Handles CloseAllToolStripMenuItem.Click
        ' Fermez tous les formulaires enfants du parent.
        For Each ChildForm As Form In Me.MdiChildren
            ChildForm.Close()
        Next
    End Sub
    Private Sub AideToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AideToolStripMenuItem.Click
        PtiC_SplitTravAide.Panel2Collapsed = Not PtiC_SplitTravAide.Panel2Collapsed
    End Sub

#End Region

#Region "Les splitters"

    'Initialisation du positionnement des splitters
    Private Sub initPosSplitters()

        'Calcul de la distance du splitter des boutons OMANE afin que les boutons
        'et le controleur qui stocke les icônes s'ajustent correctement + paramétrage des tailles min
        Dim distBoutons As Integer
        distBoutons = PtiC_RadioButton1.Height * 5 + PtiC_SplitArbo.SplitterWidth
        PtiC_SplitArbo.Panel2MinSize = PtiC_RadioButton1.Height
        PtiC_SplitArbo.Panel1MinSize = PtiC_SplitArbo.Height - distBoutons - 1

        'Réglage, en fonction de disBoutons, du splitter contenant l'arborescence et les boutons
        'ainsi que du splitter contenant la fenêtre de travail et l'aide
        PtiC_SplitArbo.SplitterDistance = PtiC_SplitArbo.Height - distBoutons
        PtiC_SplitTravAide.SplitterDistance = PtiC_SplitTravAide.Height - distBoutons

    End Sub

    'Affichage / Masquage des boutons de navigation (en dessous Arbo) en fonction de la position
    'du splitter PtiC_SplitArbo
    Private Sub PtiC_SplitArbo_SplitterMoved(ByVal sender As Object, ByVal e As System.Windows.Forms.SplitterEventArgs) Handles PtiC_SplitArbo.SplitterMoved
        'Calcul de la distance du splitter
        Dim nbBoutons, i As Integer
        nbBoutons = ((PtiC_SplitArbo.Height - PtiC_SplitArbo.SplitterDistance - PtiC_SplitArbo.SplitterWidth) / PtiC_RadioButton1.Height) - 1
        'Affichage ou non des Boutons
        For i = 1 To 4
            If Not (PtiC_SplitArbo.Panel2.Controls("PtiC_RadioButton" & CStr(i)) Is Nothing) Then
                PtiC_SplitArbo.Panel2.Controls("PtiC_RadioButton" & CStr(i)).Visible = (i <= nbBoutons)
            End If
        Next
        'Refresh()
    End Sub

    'Paramétrage des caractéristiques des splitters (incréments, tailles min et max)
    Private Sub initCaractSplitters()

        Dim distBoutons As Integer

        PtiC_SplitBase.Panel1MinSize = 100
        PtiC_SplitBase.Panel2MinSize = 740

        distBoutons = PtiC_RadioButton1.Height * 5 + PtiC_SplitArbo.SplitterWidth
        PtiC_SplitArbo.Panel2MinSize = PtiC_RadioButton1.Height
        PtiC_SplitArbo.Panel1MinSize = PtiC_SplitArbo.Height - distBoutons - 1

        PtiC_SplitArbo.SplitterIncrement = PtiC_RadioButton1.Height

    End Sub

#End Region

#Region "La treeView"

    Private Sub PtiC_trv_Arbo_AfterSelect(ByVal sender As Object, ByVal e As System.Windows.Forms.TreeViewEventArgs) Handles PtiC_trv_Arbo.AfterSelect
        Select Case e.Node.Text

            Case "Visualiser l'architecture de l'étude"
                afficheGroupe(frmProcessusEtude)

            Case "Fichier encours"
                frmDonEncours.tbc_ImportEncours.SelectedIndex = 0
                afficheGroupe(frmDonEncours)
            Case "Correspondances"
                frmDonEncours.tbc_ImportEncours.SelectedIndex = 1
                afficheGroupe(frmDonEncours)
            Case "Retraitements"
                frmDonEncours.tbc_ImportEncours.SelectedIndex = 2
                afficheGroupe(frmDonEncours)
            Case "Statistiques"
                frmDonEncours.tbc_ImportEncours.SelectedIndex = 3
                afficheGroupe(frmDonEncours)

            Case "Consultation"
                frmDonReferentielles.tbc_ImportEncours.SelectedIndex = 0
                afficheGroupe(frmDonReferentielles)
            Case "Alimentation"
                frmDonReferentielles.tbc_ImportEncours.SelectedIndex = 1
                afficheGroupe(frmDonReferentielles)

            Case "Segmentation"
                frmDonSegmentation.tbc_ImportEncours.SelectedIndex = 0
                afficheGroupe(frmDonSegmentation)
                frmDonSegmentation.tbp_Segmentation_Enter()

            Case "Méthode de calcul"
                frmDonTechniques.tbc_ImportEncours.SelectedIndex = 0
                afficheGroupe(frmDonTechniques)
            Case "Données économiques"
                frmDonTechniques.tbc_ImportEncours.SelectedIndex = 1
                afficheGroupe(frmDonTechniques)
            Case "Garanties décès / PTIA"
                frmDonTechniques.tbc_ImportEncours.SelectedIndex = 2
                afficheGroupe(frmDonTechniques)
            Case "Garanties Incapacité / Invalidité"
                frmDonTechniques.tbc_ImportEncours.SelectedIndex = 3
                afficheGroupe(frmDonTechniques)
            Case "Estimateurs"
                frmDonTechniques.tbc_ImportEncours.SelectedIndex = 4
                afficheGroupe(frmDonTechniques)
                frmDonTechniques.refreshParamEst()

            Case "Scénario central"
                If e.Node.Parent.Text = "Equilibre tarifaire" Then
                    frmResultats.tbc_ImportEncours.SelectedIndex = 0
                    afficheGroupe(frmResultats)
                ElseIf e.Node.Parent.Text = "Projection des comptes" Then
                    afficheFrm(GetType(frmResultatsModele2))
                    DirectCast(frmEnCours, frmResultatsModele2).tbc_ImportEncours.SelectedIndex = 0
                End If
            Case "Calculs Détaillés"
                If e.Node.Parent.Text = "Equilibre tarifaire" Then
                    frmResultats.tbc_ImportEncours.SelectedIndex = 1
                    afficheGroupe(frmResultats)
                ElseIf e.Node.Parent.Text = "Scénario central" Then
                    afficheFrm(GetType(frmResultatsModele2))
                    DirectCast(frmEnCours, frmResultatsModele2).tbc_ImportEncours.SelectedIndex = 1
                End If
            Case "Sensibilités"
                frmResultats.tbc_ImportEncours.SelectedIndex = 2
                afficheGroupe(frmResultats)
            Case "Stress-Tests"
                afficheGroupe(frmResultats)
                frmResultats.tbc_ImportEncours.SelectedIndex = 3
            Case "Synthèse"
                afficheGroupe(frmResultats)
                frmResultats.tbc_ImportEncours.SelectedIndex = 4

            Case "Paramétrage"
                afficheFrm(GetType(frmResultatsModele2))
                DirectCast(frmEnCours, frmResultatsModele2).tbc_ImportEncours.SelectedIndex = 0
            Case "Résultats Détaillés"
                afficheFrm(GetType(frmResultatsModele2))
                DirectCast(frmEnCours, frmResultatsModele2).tbc_ImportEncours.SelectedIndex = 2
            Case "Compte de résultat"
                afficheFrm(GetType(frmResultatsModele2))
                DirectCast(frmEnCours, frmResultatsModele2).tbc_ImportEncours.SelectedIndex = 3
            Case "Bilan"
                afficheFrm(GetType(frmResultatsModele2))
                DirectCast(frmEnCours, frmResultatsModele2).tbc_ImportEncours.SelectedIndex = 4
            Case "Indicateurs"
                afficheFrm(GetType(frmResultatsModele2))
                DirectCast(frmEnCours, frmResultatsModele2).tbc_ImportEncours.SelectedIndex = 5
            Case "Graphiques"
                afficheFrm(GetType(frmResultatsModele2))
                DirectCast(frmEnCours, frmResultatsModele2).tbc_ImportEncours.SelectedIndex = 6

            Case "Pilotage"
                afficheFrm(GetType(frmResultatsModele2simul))
                DirectCast(frmEnCours, frmResultatsModele2simul).tbc_ImportEncours.SelectedIndex = 0

            Case "Echéancier"
                afficheFrm(GetType(frmResultatsEcheancier))
                DirectCast(frmEnCours, frmResultatsEcheancier).tbc_ImportEncours.SelectedIndex = 0

        End Select
    End Sub

    Private Sub afficheGroupe(ByVal frmGroupe As Form)
        If frmEnCours.Name <> frmGroupe.Name Then
            'Fermeture ou masquage de la form en cours
            If (TypeOf frmEnCours Is frmResultatsModele2) _
                Or (TypeOf frmEnCours Is frmResultatsEcheancier) Then
                frmEnCours.Close()
            Else
                frmEnCours.Visible = False
            End If
            frmEnCours = frmGroupe
            frmGroupe.Visible = True
        End If
    End Sub

    Private Sub afficheFrm(ByVal typeForm As System.Type)

        If Not frmEnCours.GetType.Name.Equals(typeForm.Name) Then

            'Fermeture ou masquage de la form en cours
            If (TypeOf frmEnCours Is frmResultatsModele2) _
                Or (TypeOf frmEnCours Is frmResultatsEcheancier) _
                Or (TypeOf frmEnCours Is frmResultatsModele2simul) Then
                frmEnCours.Close()
            Else
                frmEnCours.Visible = False
            End If

            'Affichage de la forme
            frmEnCours = New Form
            If typeForm.Name = GetType(frmResultatsEcheancier).Name Then
                frmEnCours = New frmResultatsEcheancier(_universBDD, _controleurOMANE)
            ElseIf typeForm.Name = GetType(frmResultatsModele2).Name Then
                frmEnCours = New frmResultatsModele2(_universBDD, _controleurOMANE)
            ElseIf typeForm.Name = GetType(frmResultatsModele2simul).Name Then
                frmEnCours = New frmResultatsModele2simul(_universBDD.listeTraitements.getTraitMoteurMethode2)
            End If
            frmEnCours.MdiParent = Me
            frmEnCours.Dock = DockStyle.Fill
            frmEnCours.Visible = True
            Me.PtiC_SplitTravAide.Panel1.Controls.Add(frmEnCours)

        End If

    End Sub

#End Region

#Region "Rafraichissements invoqués par les objets métiers"

    Public Function actualise(ByVal sender As Object, ByVal notification As Object) As PTIC_Util.resultatValidationContraintes Implements PTIC_Util.IObserver.actualise
        If TypeOf sender Is UniversOMANE Then
            actualisationUniversOMANE(sender, notification)
        ElseIf sender Is _universBDD.listeTraitements.getTraitMoteurMethode2.scenarioCentral Then
            actualisationScenCentMoteur2(sender, notification)
        ElseIf TypeOf sender Is moteurTauxGaranti1.Moteur_Methode1 Then
            actualisationMoteur1(sender, notification)
        End If
        Return Nothing
    End Function
    Private Sub actualisationUniversOMANE(ByVal sender As Object, ByVal notification As Object)
        Dim notifUnivers As UniversOMANE.notification
        If notifUnivers = UniversOMANE.notification.numMethodeCalculAchange Then
            If _universBDD.numMethodeCalculEnCours = 1 Then
                deleteTreeNode("Projection des comptes", PtiC_trv_Arbo.Nodes(0))
            Else
                integreTreeNode(PtiC_trv_Arbo.Nodes(0), _saveParentNodeProjComptes, _saveNodeProjComptes)
            End If
        End If
    End Sub
    Private Sub actualisationMoteur1(ByVal sender As Object, ByVal notification As Object)
        Dim notifMoteurTxGar1 As moteurTauxGaranti1.Moteur_Methode1.notification
        If notifMoteurTxGar1 = moteurTauxGaranti1.Moteur_Methode1.notification.etatCalculScenCentralModif Or _
           notifMoteurTxGar1 = moteurTauxGaranti1.Moteur_Methode1.notification.etatCalculSimulationsModif Then
            afficheNoeudsResultatsModele1(sender)
        End If
    End Sub
    Private Sub actualisationScenCentMoteur2(ByVal sender As Object, ByVal notification As Object)
        Dim notifMoteurMethode2 As gestionCalculs.CalculIndividuel.notification = notification
        Dim scenarioCentralMoteur2 As gestionCalculs.CalculIndividuel = sender
        If notifMoteurMethode2 = gestionCalculs.CalculIndividuel.notification.ApresModifEtatCalcul Then
            afficheNoeudsResultatsModele2(scenarioCentralMoteur2)
            afficheNoeudsSimulationsModele2(scenarioCentralMoteur2)
        End If
    End Sub

    ''' <summary>
    ''' Suppression d'un noeud après sauvegarde.
    ''' Utilisé pour masquer la projection des comptes lorsque le moteur 1 est sélectionné
    ''' </summary>
    ''' <param name="txtNoeudASupprimer"></param>
    ''' <param name="noeudRacine"></param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Function deleteTreeNode(ByVal txtNoeudASupprimer As String, ByVal noeudRacine As TreeNode)
        For Each node As TreeNode In noeudRacine.Nodes
            If node.Text = txtNoeudASupprimer Then
                _saveNodeProjComptes = node
                _saveParentNodeProjComptes = noeudRacine
                node.Remove()
            End If
            deleteTreeNode(txtNoeudASupprimer, node)
        Next
        Return True
    End Function
    ''' <summary>
    ''' Restauration d'un noeud. Utilisé pour afficher la projection des comptes lors d'un changement de méthode
    ''' </summary>
    ''' <param name="noeudRacine"></param>
    ''' <param name="noeudParent"></param>
    ''' <param name="NoeudAintegrer"></param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Function integreTreeNode(ByVal noeudRacine As TreeNode, _
                                    ByVal noeudParent As TreeNode, _
                                    ByVal NoeudAintegrer As TreeNode)
        For Each node As TreeNode In noeudRacine.Nodes
            If node.Text = noeudParent.Text Then node.Nodes.Add(NoeudAintegrer)
            integreTreeNode(node, noeudParent, NoeudAintegrer)
        Next
        Return True
    End Function

    Public Sub afficheNoeudsResultatsModele2(ByVal scenarioCentralMoteur2 As gestionCalculs.CalculIndividuel)

        Dim treeNodeCalculsDetailles As New TreeNode
        treeNodeCalculsDetailles.ForeColor = System.Drawing.Color.FromArgb(127, 0, 255) '127; 0; 255
        treeNodeCalculsDetailles.ImageKey = "calculator.png"
        treeNodeCalculsDetailles.Name = "NoeudCalculsDetailles"
        treeNodeCalculsDetailles.NodeFont = New System.Drawing.Font("Tahoma", 9.0!, System.Drawing.FontStyle.Underline, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        treeNodeCalculsDetailles.SelectedImageKey = "calculator.png"
        treeNodeCalculsDetailles.Text = "Calculs Détaillés"

        Dim treeNodeResultatsDetailles As New TreeNode
        treeNodeResultatsDetailles.ForeColor = System.Drawing.Color.FromArgb(127, 0, 255)
        treeNodeResultatsDetailles.ImageKey = "chart_line.png"
        treeNodeResultatsDetailles.Name = "NoeudResultatsDetailles"
        treeNodeResultatsDetailles.NodeFont = New System.Drawing.Font("Tahoma", 9.0!, System.Drawing.FontStyle.Underline, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        treeNodeResultatsDetailles.SelectedImageKey = "chart_line.png"
        treeNodeResultatsDetailles.Text = "Résultats Détaillés"

        Dim treeNodeCompteDeResultat As New TreeNode
        treeNodeCompteDeResultat.ForeColor = System.Drawing.Color.FromArgb(127, 0, 255)
        treeNodeCompteDeResultat.ImageKey = "grid.png"
        treeNodeCompteDeResultat.Name = "NoeudCompteDeResultat"
        treeNodeCompteDeResultat.NodeFont = New System.Drawing.Font("Tahoma", 9.0!, System.Drawing.FontStyle.Underline, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        treeNodeCompteDeResultat.SelectedImageKey = "grid.png"
        treeNodeCompteDeResultat.Text = "Compte de résultat"

        Dim treeNodeBilan As New TreeNode
        treeNodeBilan.ForeColor = System.Drawing.Color.FromArgb(127, 0, 255)
        treeNodeBilan.ImageKey = "grid.png"
        treeNodeBilan.Name = "NoeudBilan"
        treeNodeBilan.NodeFont = New System.Drawing.Font("Tahoma", 9.0!, System.Drawing.FontStyle.Underline, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        treeNodeBilan.SelectedImageKey = "grid.png"
        treeNodeBilan.Text = "Bilan"

        Dim treeNodeIndicateurs As New TreeNode
        treeNodeIndicateurs.ForeColor = System.Drawing.Color.FromArgb(127, 0, 255)
        treeNodeIndicateurs.ImageKey = "report.png"
        treeNodeIndicateurs.Name = "NoeudIndicateurs"
        treeNodeIndicateurs.NodeFont = New System.Drawing.Font("Tahoma", 9.0!, System.Drawing.FontStyle.Underline, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        treeNodeIndicateurs.SelectedImageKey = "report.png"
        treeNodeIndicateurs.Text = "Indicateurs"

        Dim treeNodeGraphiques As New TreeNode
        treeNodeGraphiques.ForeColor = System.Drawing.Color.FromArgb(127, 0, 255)
        treeNodeGraphiques.ImageKey = "vector.png"
        treeNodeGraphiques.Name = "NoeudGraphiques"
        treeNodeGraphiques.NodeFont = New System.Drawing.Font("Tahoma", 9.0!, System.Drawing.FontStyle.Underline, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        treeNodeGraphiques.SelectedImageKey = "vector.png"
        treeNodeGraphiques.Text = "Graphiques"

        With PtiC_trv_Arbo.Nodes(0).Nodes(0).Nodes(2).Nodes(1).Nodes(0)
            If scenarioCentralMoteur2.etatCalcul = valueEtatCalcul.A_JOUR Then
                If Not .Nodes.ContainsKey(treeNodeCalculsDetailles.Name) Then .Nodes.Add(treeNodeCalculsDetailles)
                If Not .Nodes.ContainsKey(treeNodeResultatsDetailles.Name) Then .Nodes.Add(treeNodeResultatsDetailles)
                If Not .Nodes.ContainsKey(treeNodeCompteDeResultat.Name) Then .Nodes.Add(treeNodeCompteDeResultat)
                If Not .Nodes.ContainsKey(treeNodeBilan.Name) Then .Nodes.Add(treeNodeBilan)
                If Not .Nodes.ContainsKey(treeNodeIndicateurs.Name) Then .Nodes.Add(treeNodeIndicateurs)
                If Not .Nodes.ContainsKey(treeNodeGraphiques.Name) Then .Nodes.Add(treeNodeGraphiques)
            Else
                If .Nodes.ContainsKey(treeNodeCalculsDetailles.Name) Then .Nodes.RemoveByKey(treeNodeCalculsDetailles.Name)
                If .Nodes.ContainsKey(treeNodeResultatsDetailles.Name) Then .Nodes.RemoveByKey(treeNodeResultatsDetailles.Name)
                If .Nodes.ContainsKey(treeNodeCompteDeResultat.Name) Then .Nodes.RemoveByKey(treeNodeCompteDeResultat.Name)
                If .Nodes.ContainsKey(treeNodeBilan.Name) Then .Nodes.RemoveByKey(treeNodeBilan.Name)
                If .Nodes.ContainsKey(treeNodeIndicateurs.Name) Then .Nodes.RemoveByKey(treeNodeIndicateurs.Name)
                If .Nodes.ContainsKey(treeNodeGraphiques.Name) Then .Nodes.RemoveByKey(treeNodeGraphiques.Name)
            End If
        End With
    End Sub
    Public Sub afficheNoeudsSimulationsModele2(ByVal scenarioCentralMoteur2 As gestionCalculs.CalculIndividuel)

        Dim treeNodeSimulM2_Titre As New TreeNode
        treeNodeSimulM2_Titre.ForeColor = System.Drawing.Color.FromArgb(0, 0, 0)
        treeNodeSimulM2_Titre.ImageKey = "chart_curve.png.png"
        treeNodeSimulM2_Titre.Name = "NoeudSimulM2_Pilotage"
        treeNodeSimulM2_Titre.NodeFont = New System.Drawing.Font("Tahoma", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        treeNodeSimulM2_Titre.SelectedImageKey = "chart_curve.png.png"
        treeNodeSimulM2_Titre.Text = "Simulations"

        Dim treeNodeSimulM2_Pilotage As New TreeNode
        treeNodeSimulM2_Pilotage.ForeColor = System.Drawing.Color.FromArgb(127, 0, 255)
        treeNodeSimulM2_Pilotage.ImageKey = "vector.png"
        treeNodeSimulM2_Pilotage.Name = "NoeudSimulM2_Pilotage"
        treeNodeSimulM2_Pilotage.NodeFont = New System.Drawing.Font("Tahoma", 9.0!, System.Drawing.FontStyle.Underline, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        treeNodeSimulM2_Pilotage.SelectedImageKey = "vector.png"
        treeNodeSimulM2_Pilotage.Text = "Pilotage"

        With PtiC_trv_Arbo.Nodes(0).Nodes(0).Nodes(2).Nodes(1)
            If scenarioCentralMoteur2.etatCalcul = valueEtatCalcul.A_JOUR Then
                If Not .Nodes.ContainsKey(treeNodeSimulM2_Titre.Name) Then .Nodes.Add(treeNodeSimulM2_Titre)
                If Not .Nodes(1).Nodes.ContainsKey(treeNodeSimulM2_Pilotage.Name) Then .Nodes(1).Nodes.Add(treeNodeSimulM2_Pilotage)
            Else
                If .Nodes.ContainsKey(treeNodeSimulM2_Titre.Name) Then .Nodes.RemoveByKey(treeNodeSimulM2_Titre.Name)
            End If
        End With
    End Sub
    Public Sub afficheNoeudsResultatsModele1(ByVal moteur1 As moteurTauxGaranti1.Moteur_Methode1)

        Dim treeNodeCalculsDetaillesMoteur1 As New TreeNode
        treeNodeCalculsDetaillesMoteur1.Name = "treeNodeCalculsDetaillesMoteur1"
        treeNodeCalculsDetaillesMoteur1.ForeColor = System.Drawing.Color.FromArgb(CType(CType(127, Byte), Integer), CType(CType(0, Byte), Integer), CType(CType(255, Byte), Integer))
        treeNodeCalculsDetaillesMoteur1.ImageKey = "chart_curve.png"
        treeNodeCalculsDetaillesMoteur1.NodeFont = New System.Drawing.Font("Tahoma", 9.0!, System.Drawing.FontStyle.Underline)
        treeNodeCalculsDetaillesMoteur1.SelectedImageKey = "chart_curve.png"
        treeNodeCalculsDetaillesMoteur1.Text = "Calculs Détaillés"

        Dim treeNodeSensibilitesMoteur1 As New TreeNode
        treeNodeSensibilitesMoteur1.Name = "treeNodeSensibilitesMoteur1"
        treeNodeSensibilitesMoteur1.ForeColor = System.Drawing.Color.FromArgb(CType(CType(127, Byte), Integer), CType(CType(0, Byte), Integer), CType(CType(255, Byte), Integer))
        treeNodeSensibilitesMoteur1.ImageKey = "vector.png"
        treeNodeSensibilitesMoteur1.NodeFont = New System.Drawing.Font("Tahoma", 9.0!, System.Drawing.FontStyle.Underline)
        treeNodeSensibilitesMoteur1.SelectedImageKey = "vector.png"
        treeNodeSensibilitesMoteur1.Text = "Sensibilités"

        Dim treeNodeStressTestMoteur1 As New TreeNode
        treeNodeStressTestMoteur1.Name = "treeNodeStressTestMoteur1"
        treeNodeStressTestMoteur1.ForeColor = System.Drawing.Color.FromArgb(CType(CType(127, Byte), Integer), CType(CType(0, Byte), Integer), CType(CType(255, Byte), Integer))
        treeNodeStressTestMoteur1.ImageIndex = 36
        treeNodeStressTestMoteur1.NodeFont = New System.Drawing.Font("Tahoma", 9.0!, System.Drawing.FontStyle.Underline)
        treeNodeStressTestMoteur1.SelectedImageIndex = 36
        treeNodeStressTestMoteur1.Text = "Stress-Tests"

        Dim treeNodeSyntheseMoteur1 As New TreeNode
        treeNodeSyntheseMoteur1.Name = "treeNodeSyntheseMoteur1"
        treeNodeSyntheseMoteur1.ForeColor = System.Drawing.Color.FromArgb(CType(CType(127, Byte), Integer), CType(CType(0, Byte), Integer), CType(CType(255, Byte), Integer))
        treeNodeSyntheseMoteur1.ImageKey = "compass.png"
        treeNodeSyntheseMoteur1.NodeFont = New System.Drawing.Font("Tahoma", 9.0!, System.Drawing.FontStyle.Underline)
        treeNodeSyntheseMoteur1.SelectedImageKey = "compass.png"
        treeNodeSyntheseMoteur1.Text = "Synthèse"

        With PtiC_trv_Arbo.Nodes(0).Nodes(0).Nodes(2).Nodes(0)
            If moteur1.etatCalculScenCentral = valueEtatCalcul.A_JOUR Then
                If Not .Nodes.ContainsKey(treeNodeCalculsDetaillesMoteur1.Name) Then .Nodes.Add(treeNodeCalculsDetaillesMoteur1)
            Else
                If .Nodes.ContainsKey(treeNodeCalculsDetaillesMoteur1.Name) Then .Nodes.RemoveByKey(treeNodeCalculsDetaillesMoteur1.Name)
            End If
            If moteur1.etatCalculSimulations = valueEtatCalcul.A_JOUR Then
                If Not .Nodes.ContainsKey(treeNodeSensibilitesMoteur1.Name) Then .Nodes.Add(treeNodeSensibilitesMoteur1)
                If Not .Nodes.ContainsKey(treeNodeStressTestMoteur1.Name) Then .Nodes.Add(treeNodeStressTestMoteur1)
                If Not .Nodes.ContainsKey(treeNodeSyntheseMoteur1.Name) Then .Nodes.Add(treeNodeSyntheseMoteur1)
            Else
                If .Nodes.ContainsKey(treeNodeSensibilitesMoteur1.Name) Then .Nodes.RemoveByKey(treeNodeSensibilitesMoteur1.Name)
                If .Nodes.ContainsKey(treeNodeStressTestMoteur1.Name) Then .Nodes.RemoveByKey(treeNodeStressTestMoteur1.Name)
                If .Nodes.ContainsKey(treeNodeSyntheseMoteur1.Name) Then .Nodes.RemoveByKey(treeNodeSyntheseMoteur1.Name)
            End If
        End With
    End Sub

#End Region

End Class

